package cn.shafish.dubbo.annotation.consumer.controller;

import cn.shafish.serviceapi.dto.UserDTO;
import cn.shafish.serviceapi.service.UserRpcService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @DubboReference(version = "${dubbo.consumer.user-service.version}")
    private UserRpcService userRpcService;

    @GetMapping("get")
    public String getUserInfo(Integer id) {
        UserDTO user = userRpcService.getUser(id);
        return user.toString();
    }

}
